% Get table of a stock including stock code, date, and close price
% Input: stock_code
% Output: stock_code, date, close_price
function [stock_code date close_price volume] = getStock(stock_code)

    % the query is used to access the database to get table of the stock stock_code
    query = strcat('select t.Date, s.Name, t.ClosePrice, t.Volume from security s, transaction t where s.ID = t.ID_Security and s.Name =', '''', stock_code, ''';');

    % get the output table after using the query to access the database
    output_table = selectData(query);

    if (~isempty(output_table)) % the stock is exists => get data from output_table
        date = cell2mat(output_table(:, 1));
        date = datenum(date);
        close_price = cell2mat(output_table(:, 3));
        volume = cell2mat(output_table(:, 4));
    else % the stock is not exists => set data null
        stock_code = [];
        date = [];
        close_price = [];
        volume = 0;
    end
end